<?php

namespace app\admin\model\select;

use think\Model;


class Order extends Model
{

    

    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'o_create_time_text',
        'o_update_time_text'
    ];

    public function getSpecsList()
    {
        return ['单瓶' => '单瓶','整箱' => '整箱', '2瓶/箱' => '2瓶/箱', '4瓶/箱' => '4瓶/箱', '6瓶/箱' => '6瓶/箱', '12瓶/箱' => '12瓶/箱', '其他' => '其他'];
    }


    public function getSpecsStatusList()
    {
        return ['单瓶' => 1,'2瓶/箱' => 2, '4瓶/箱' => 3, '6瓶/箱' => 4, '12瓶/箱' => 5, '其他' => 6, '整箱' => 7];
    }

    public function getIsFearQueryList()
    {
        return ['0' => '不怕查', '1' => '怕查'];
    }






    public function getOCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['o_create_time']) ? $data['o_create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getOUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['o_update_time']) ? $data['o_update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setOCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setOUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
